<template>
	<view class="container">
		<view class="items" v-if="list.length>0">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="left">{{item.money>0?'+'+item.money:item.money}}</view>
				<view class="center">{{item.desc}}</view>
				<view class="time">{{item.time_text}}</view>
			</view>
			<u-loadmore :status="hasMore?'loading':'nomore'" />
		</view>
		<view class="empty-container" v-else>
			<u-empty text="暂无相关数据" :icon="emptyIcon"></u-empty>
		</view>
	</view>
</template>

<script>
	var _this;
	export default {
		data() {
			return {
				emptyIcon:'https://farm-city.oss-cn-hangzhou.aliyuncs.com/static/common/empty.png',
				list: [],
				pageIndex: 1,
				hasMore:true,
				u_wid:0
			};
		},
		onLoad(e) {
			_this=this;
			if(e.u_wid){
				_this.u_wid=e.u_wid
			}
			_this.get_my_wallet_log()
		},
		onReachBottom() {
			if(_this.hasMore){
				_this.pageIndex++
				_this.get_my_wallet_log()
			}
		},
		methods:{
			async get_my_wallet_log() {
				const params = {
					u_wid: _this.u_wid,
					pageIndex: _this.pageIndex,
					pageSize: 20,
				}
				const data = await _this.$post('api/get_my_wallet_log',params)
				if(data.code==200){
					_this.list.push(...data.data.list)
					_this.hasMore=data.data.list.length>=params.pageSize
				}else{
					_this.hasMore=false
				}
			}
		},
		onShow() {},
	}
</script>

<style lang="scss" scoped>
.container{
	.items{
		.item{
			height: 100rpx;
			background: #fff;
			border-radius: 20rpx;
			@include flex-box(row,null,center);
			padding: 0 30rpx;
			font-size: 28rpx;
			margin-bottom: 20rpx;
			>view{
				flex: 1;
			}
			.time{
				text-align: right;
			}
		}
	}
}
</style>
